//
//  SiginingViewController.m
//  xingfugangwan
//
//  Created by rainday on 14/12/28.
//  Copyright (c) 2014年 rainday. All rights reserved.
//

#import "SiginingViewController.h"
#import "SignView.h"
#import <QuartzCore/QuartzCore.h>

@interface SiginingViewController ()
@property (nonatomic ,weak) IBOutlet SignView *signView;

- (IBAction)dismissVC:(id)sender;
- (IBAction)completeSigining:(id)sender;

@end

@implementation SiginingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (void)dismissVC:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}



- (void)completeSigining:(id)sender
{
    if ([_delegate respondsToSelector:@selector(saveSign:)]) {
        [_delegate saveSign:[self getImageFromView:_signView]];
        [self dismissViewControllerAnimated:YES completion:nil];
    }
}

-(UIImage *)getImageFromView:(UIView *)orgView{
    UIGraphicsBeginImageContext(orgView.bounds.size);
    [orgView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}

@end
